From 5166d94a6a45cb48946009f5d4b2acf9f7d78243 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Fri, 6 Apr 2007 22:48:25 +0100 Subject: [PATCH] libxc: Clarify xc_mmu interface and make it private. Signed-off-by: Keir Fraser --- tools/libxc/xc_domain_restore.c | 14 ++++++++------ tools/libxc/xc_private.c | 10 +++++----- tools/libxc/xc_private.h | 12 ++++++++++++ tools/libxc/xenctrl.h | 15 --------------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c index 624c675b9e..e1bc0c02c2 100644 --- a/tools/libxc/xc_domain_restore.c +++ b/tools/libxc/xc_domain_restore.c @@ -284,7 +284,7 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom, /* Our mapping of the current region (batch) */ char *region_base; - xc_mmu_t *mmu = NULL; + struct xc_mmu *mmu = NULL; /* used by debug verify code */ unsigned long buf[PAGE_SIZE/sizeof(unsigned long)]; @@ -386,7 +386,9 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom, for ( pfn = 0; pfn < p2m_size; pfn++ ) p2m[pfn] = INVALID_P2M_ENTRY; - if(!(mmu = xc_init_mmu_updates(xc_handle, dom))) { + mmu = xc_alloc_mmu_updates(xc_handle, dom); + if ( mmu == NULL ) + { ERROR("Could not initialise for MMU updates"); goto out; } @@ -629,8 +631,8 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom, * Ensure we flush all machphys updates before potential PAE-specific * reallocations below. */ - if (!hvm && xc_finish_mmu_updates(xc_handle, mmu)) { - ERROR("Error doing finish_mmu_updates()"); + if (!hvm && xc_flush_mmu_updates(xc_handle, mmu)) { + ERROR("Error doing flush_mmu_updates()"); goto out; } @@ -810,8 +812,8 @@ int xc_domain_restore(int xc_handle, int io_fd, uint32_t dom, } } - if (xc_finish_mmu_updates(xc_handle, mmu)) { - ERROR("Error doing finish_mmu_updates()"); + if (xc_flush_mmu_updates(xc_handle, mmu)) { + ERROR("Error doing xc_flush_mmu_updates()"); goto out; } } diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index 3e2557e581..9ac035f8af 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -145,7 +145,7 @@ int xc_mmuext_op( return ret; } -static int flush_mmu_updates(int xc_handle, xc_mmu_t *mmu) +static int flush_mmu_updates(int xc_handle, struct xc_mmu *mmu) { int err = 0; DECLARE_HYPERCALL; @@ -180,9 +180,9 @@ static int flush_mmu_updates(int xc_handle, xc_mmu_t *mmu) return err; } -xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom) +struct xc_mmu *xc_alloc_mmu_updates(int xc_handle, domid_t dom) { - xc_mmu_t *mmu = malloc(sizeof(xc_mmu_t)); + struct xc_mmu *mmu = malloc(sizeof(*mmu)); if ( mmu == NULL ) return mmu; mmu->idx = 0; @@ -190,7 +190,7 @@ xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom) return mmu; } -int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu, +int xc_add_mmu_update(int xc_handle, struct xc_mmu *mmu, unsigned long long ptr, unsigned long long val) { mmu->updates[mmu->idx].ptr = ptr; @@ -202,7 +202,7 @@ int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu, return 0; } -int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu) +int xc_flush_mmu_updates(int xc_handle, struct xc_mmu *mmu) { return flush_mmu_updates(xc_handle, mmu); } diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index 7fa3258db1..09e1bdf4ad 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -168,4 +168,16 @@ void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits); /* Optionally flush file to disk and discard page cache */ void discard_file_cache(int fd, int flush); +#define MAX_MMU_UPDATES 1024 +struct xc_mmu { + mmu_update_t updates[MAX_MMU_UPDATES]; + int idx; + domid_t subject; +}; +/* Structure returned by xc_alloc_mmu_updates must be free()'ed by caller. */ +struct xc_mmu *xc_alloc_mmu_updates(int xc_handle, domid_t dom); +int xc_add_mmu_update(int xc_handle, struct xc_mmu *mmu, + unsigned long long ptr, unsigned long long val); +int xc_flush_mmu_updates(int xc_handle, struct xc_mmu *mmu); + #endif /* __XC_PRIVATE_H__ */ diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 22894d1006..1073b8bcb5 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -666,21 +666,6 @@ int xc_sysctl(int xc_handle, struct xen_sysctl *sysctl); int xc_version(int xc_handle, int cmd, void *arg); -/* - * MMU updates. - */ -#define MAX_MMU_UPDATES 1024 -struct xc_mmu { - mmu_update_t updates[MAX_MMU_UPDATES]; - int idx; - domid_t subject; -}; -typedef struct xc_mmu xc_mmu_t; -xc_mmu_t *xc_init_mmu_updates(int xc_handle, domid_t dom); -int xc_add_mmu_update(int xc_handle, xc_mmu_t *mmu, - unsigned long long ptr, unsigned long long val); -int xc_finish_mmu_updates(int xc_handle, xc_mmu_t *mmu); - int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size); /* -- 2.30.2